﻿$(function () {
       //导航菜单
    var $menuList = $("#hd-nav li"), $menuContent = $("#menuItem2").find(".mdetail"), $menuContainer = $("#menuItem2");
    var hdmenu = {
        showMenu: function (i) {
            var n = i, me = this, $winWidth = ($(window).width() >= 980) ? $(window).width() : 980, showfun;
            clearTimeout(me.hideMenuTimer);
            showfun = function () {
                if ($menuList.eq(n).hasClass("noSubmenu")) {
                    me.hideMenu();
                    return false;
                }
                else {
                    $menuList.eq(n).addClass('hover');
                }
                if ($.browser.msie && $.browser.version == 6) {
                    $("#selectMask").height($menuContent.eq(n - 1).height() + 11).width($menuContent.eq(n - 1).width() + 4);
                }
                $menuList.eq(n).siblings().removeClass('hover');
                $menuContainer.css({ visibility: "visible" });
                $menuContent.css("visibility", "hidden");
                $menuContent.eq(n - 1).css("visibility", "visible");
                $menuContainer.css("left", (($winWidth - 980) / 2) + 46 * (n - 1));
                $menuContainer.css("top", $('#hd').height());
            }
            me.showMenuTimer = setTimeout(showfun, 80)
        },
        hideMenu: function () {
            var me = this, hidefun;
            clearTimeout(me.showMenuTimer);
            hidefun = function () {
                $menuList.removeClass('hover');
                $menuContainer.css({ visibility: "hidden" });
                $menuContent.css("visibility", "hidden");
            }
            me.hideMenuTimer = setTimeout(hidefun, 80)
        },
        int: function () {
            $menuList.hover(function () {
                var n = $menuList.index($(this));
                hdmenu.showMenu(n)
            }, function () {
                hdmenu.hideMenu();
            })
            $menuContent.hover(function () {
                var n = $menuContent.index($(this));
                hdmenu.showMenu(n + 1);
            }, function () {
                hdmenu.hideMenu();
            })
        }
    }
    //购物车数量
    if (window.cartItemSum !== undefined) {
        $('#hd-cart-amount').text(cartItemSum);
    }
    //顶部slide
    $("#headSlide-box").append($("#headSlide"));
    $("#headSlide").css("visibility", "visible")
    hdmenu.int();

    //顶部下拉菜单
    $("li.hd-qbar-list-drop").hover(function () {
        $(this).find("ul").show();
    }, function () {
        $(this).find("ul").hide();
    });
});